﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmApiLibrary.libs
{
    public interface IWeiBo
    {
        void SetOAuth(string token, string secret);
        string AddWeiBoPic(string text, string picture);
        string AddWeiBo(string text);
        string GetUserId();
        bool IsEnabled { get; }
        WeiBoType UserType { get; }
        OAuthBase GetOAuth();
    }
    public enum WeiBoType
    {
        Sina,
        QQ,
        Sohu
    }
    public class WeiboFactory
    {
        /// <summary>
        /// Create WeiBeeQQ, WeiBeeSohu, or WeiBeeSina according to the WeiBeeType specified
        /// </summary>
        /// <param name="t">type of WeiBee</param>
        /// <returns>IWeiBee</returns>
        public static IWeiBo CreateWeiBoByType(WeiBoType t)
        {
            if (dict[t] == null) return null;
            return dict[t]();
        }

        static Dictionary<WeiBoType, Func<IWeiBo>> dict = new Dictionary<WeiBoType, Func<IWeiBo>>()
            { 
                {WeiBoType.QQ, () => new WeiBoQQ() },
                {WeiBoType.Sohu, () => new WeiBoSohu() },
                {WeiBoType.Sina, () => new WeiBoSina() }
            };
    }
}
